@extends('admin.layout')
@section('title','商品列表')
@section('body')

    <div id="search" style="height:63px;">
        <blockquote class="layui-elem-quote" style="font-size: 14px">
            <form action="" method="post" class="layui-form">
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <a href="javascript:history.back()" class="layui-btn layui-btn-small" >返回</a>
                        <div  onclick="ins();" class="layui-btn layui-btn-small" >添加</div>
                    </div>
                </div>
            </form>
        </blockquote>
    </div>
    <table class="layui-table " >
        <colgroup>

        </colgroup>
        <thead>
        <tr>
            <th>品名</th>
            <th>封面</th>
            <th>库存</th>
            <th>价格</th>
            <th>商品编号</th>
            <th>更新时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($goods as $value)
            <tr class="@if($value->status==1) bg-success @elseif($value->status==2)bg-danger  @else bg-warning @endif">
                <td>{{$value->name}}</td>
                <td><img style="width: 80px;height: 80px" src="{{url($value->cover->pic_path)}}" alt=""></td>
                <td>{{$value->stock}}</td>
                <td>{{$value->price}}</td>
                <td>{{$value->goods_sn}}</td>
                <td>{{$value->updated_at}}</td>
                <td >
                    <button  class="btn btn-danger"  onclick="del('{{$value->hot_goods_id}}')">删除</button>
                </td>
            </tr>

        @endforeach
        </tbody>
    </table>
@endsection
@section('js')

    <script>
        @if(Session::has('message'))
             layer.msg("{{Session::get("message")}}");
        {{Session::forget('message')}}
        @endif




        function del(id) {
            layer.open({
                title:"提示",
                content:'确定从“猜你喜欢”吗？！<form id="down" method="post" action="{{url('goods/like')}}"><input type="hidden" name="del" value="'+id+'">{{csrf_field()}}</form>',
                yes:function () {
                    $("#down").submit();
                }
            })
        }


        function ins(id) {
            layer.open({
                title:"请填写商品编号",
                content:'<form id="down" method="post" action="{{url('goods/like')}}"><input placeholder="G123456789" type="text" name="ins" class="form-control" value="">{{csrf_field()}}</form>',
                yes:function () {
                    $("#down").submit();
                }
            })
        }



    </script>

@endsection

